package com.link.base.base.interinfo.controller;

import com.link.base.base.interinfo.model.InterInfo;
import com.link.base.base.interinfo.service.InterInfoService;
import com.link.core.basic.controller.BasicController;
import com.link.core.basic.service.BasicService;
import com.link.core.basic.service.BasicServiceException;
import com.link.core.basic.service.KeyGenerateService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 接口详情信息-接口详情信息 
 *
 * @author 秦学刚
 * @date 2019/07/01 21:11
 */
@Controller
@RequestMapping("/link/interInfo")
public class InterInfoController extends BasicController<InterInfo> {

    @Resource
    private KeyGenerateService keyGenerateService;

    @Resource
    private InterInfoService interInfoService;

    @Override
    public BasicService<InterInfo> getBasicService() throws Exception {
        return interInfoService;
    }

    /**
     * 新建或更新一条记录
     */
    @RequestMapping(value = "/unSelectInterList")
    @ResponseBody
    public Map<String, Object> unSelectInterList(InterInfo entity, HttpSession session,
                                                 HttpServletRequest request, HttpServletResponse response) {
        Map<String, Object> result = new HashMap<>();
        try {
            List<InterInfo> list = interInfoService.unSelectInterList(entity);
            result.put("rows", list);
            result.put("success", true);
        } catch (BasicServiceException e) {
            result.put("success", false);
            result.put("rows", new ArrayList<InterInfo>());
            result.put("result", e.getMessage());
            result.put("detailMessage", e.getDetailMessage());
        } catch (Exception e) {
            result.put("success", false);
            result.put("rows", new ArrayList<InterInfo>());
            result.put("result", e.getMessage());
        }
        return result;
    }
}
